#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>

int main(int argc, char const *argv[])
{
    int fd,fd2;
    int n = 0;
    fd = open(argv[1], O_RDONLY);
    fd2 = open(argv[2], O_RDWR | O_CREAT | O_TRUNC, 0664);
    // printf("fd = %d,errno=%d:%s\n", fd, errno, strerror(errno));
    char buffer[1024];
    while((n = read(fd, buffer, 1024)) != 0){
        write(fd2, buffer, n);
    }
    close(fd);
    close(fd2);
    return 0;
}
